package pl.edu.pw.perg.compinfodb.entities.attribute;

import pl.edu.pw.perg.compinfodb.entities.IPhysicalElement;
import pl.edu.pw.perg.compinfodb.entities.field.Field;

public class TextAttribute extends Attribute {

	/**
	 *
	 */
	private static final long serialVersionUID = -8478586340126411331L;

	private String textValue;

	public TextAttribute(String text, Field field, IPhysicalElement e){
		super(field, e);
		textValue = text;
	}


	public TextAttribute(Field field, IPhysicalElement e){
		super(field, e);
	}

	public TextAttribute(){
		super();
	}
	public String getTextValue() {
		return textValue;
	}

	public void setTextValue(String textValue) {
		this.textValue = textValue;
	}

	@Override
	public String toString() {
		return textValue;
	}

	public boolean matchesFilter(IAttribute a){
		if(a == null || a.getTextValue() == null)
			return true;
		String filter = a.getTextValue();
		if(textValue.contains(filter))
			return true;
		return false;
	}
}
